Next | Prev | Up | Top | Contents | Index

Example of Scheduling Separate Programs

The code in directory /usr/react/src/examples/mprogs does the same work as example simple (see "Basic Example"). However, the activity processes A and B are physically loaded as separate commands. The main program establishes the single Frame Scheduler. The activity processes are started as separate programs. They communicate with the main program using SVR4-compatible interprocess communication messages (see the intro(2) and msgget(2) reference pages).

There are three separate executables in the mprogs example. The master program, in master.c, is a command that has the following syntax:

master [-p cpu-number] [-s slave-count]

The cpu-number specifies which processor to use for the one Frame Scheduler this program creates. The default is processor 1. The slave-count tells the master how many subordinate programs will be enqueued to the Frame Scheduler. The default is two programs.

The problems that need to be solved in this example are as follows:

There are many ways in which these objectives could be met (for example, the three programs could share a shared-memory arena). In this example, the master and subordinates communicate using a simple protocol of messages exchanged using msgget() and msgput() (see the msgget(2) and msgput(2) reference pages). The sequence of operations is as follows:

  1. The master program creates a Frame Scheduler.

  2. The master sends a message inviting the most important subordinate to reply. (All the message queue handling is in module ipc.c, which is linked by all three programs.)

  3. The subordinate compiled from the file processA.c replies to this message, sending its process ID and requesting the FRS handle.

  4. The subordinate process A sends a series of messages, one for each minor queue on which it should enqueue. The master enqueues it as requested.

  5. The subordinate process A sends a "ready" message.

  6. The master sends a message inviting the next most important process to reply.

  7. The program compiled from processB.c will reply to this request, and steps 3-6 are repeated for as many slaves as the slave-count parameter to the master program. (Only two slaves are provided. However, you can easily create more using processB.c as a pattern.)

  8. The master issues frs_start(), and waits for the termination signal.

  9. The subordinates independently issue frs_join() and the real-time dispatching begins.

Next | Prev | Up | Top | Contents | Index